package com.ljx.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/18 10:06
 * @Version 1.0
 * 定义定时器的业务类
 */
@Configuration // 创建swagger配置类--所有的功能都集成在DocKet类
@EnableSwagger2
public class MySwaggerConfig {
	@Bean
	public Docket docket(){
		Docket docket = new Docket(DocumentationType.SWAGGER_2)
				// 组名
				.groupName("李吉星")
				// api 文档信息
				.apiInfo(getInfo())
				// 选择那些生成api接口--根据1请求路径选择2，根据包名选择
				.select()
				// 根据请求路径选择
//				.paths(Predicates.and(PathSelectors.regex("/dept/.*")))
				// 根据包名选择
				.apis(RequestHandlerSelectors.basePackage("com.fourth.controller"))
				.build()
				;
		return docket;
	}

	private ApiInfo getInfo(){
		Contact contact = new Contact("李吉星","http://www.jd.com","111@qq.com");
		ApiInfo apiInfo = new ApiInfo(
				"在线预约",
				"在线预约API","2.0",
				"http://www.baidu.com",
				contact,"漫动者",
				"http://www.baidu.com",
				new ArrayList<VendorExtension>());

		return apiInfo;
	}

}
